<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class MY_Controller extends MX_Controller {
	
	var $access = array();
	
	function __construct(){
	
		parent::__construct();
		
		$this->load->model('setting/model_setting');
		
		// $this->auth->update_logged();
		
		$setting = $this->model_setting->get();
		foreach($setting->result_array() as $row){
			$this->config->set_item($row['name'], $row['value']);
		}
		
		if($this->session->userdata('login') === TRUE){
			
			// $this->auth->lastLogin();
			
			if($this->session->userdata('group') != 1){
				if($this->config->item('site_offline') == "yes"){
					if(strpos($this->uri->uri_string(),"page/offline") === FALSE)
						redirect('page/offline');
				}
			}
			
			// if(!$this->auth->check_token()){
				// $this->session->set_flashdata('error', '<br />Session Anda telah dimatikan karena ada user yang sama dalam satu sistem.');
				// redirect('sessions/login');
			// }
			
			$this->access = $this->auth->get_access();
		}
		
		date_default_timezone_set("Asia/Jakarta");		
	}
}